<template>
  <div>
    <router-link to="/Contacts/addContacts"><div class="add_customer"></div></router-link>
    <h1>联系人</h1>
    <table class="table table-striped">
      <thead>
      <tr>
        <th>姓名</th>
        <th>手机</th>
        <th></th>
      </tr>
      </thead>
      <tbody v-for="customer in customers" :key="customer.id">
      <tr class="success">
        <td>{{customer.name}}</td>
        <td>{{customer.mobilephone}}</td>
        <td><router-link class="btn btn-default" v-bind:to="'/Contacts/' + customer.id">详情</router-link></td>
      </tr>
      </tbody>
    </table>

  </div>
</template>

<script>
export default {
  name: 'Center',
  data () {
    return {
      customers: {}
    }
  },
  methods: {
    fetchCustomers () {
      this.$http.get('http://localhost:3000/users')
        .then(function (response) {
          console.log(response)
          this.customers = response.body
        })
    }
  },
  created () {
    this.fetchCustomers()
  }
}
</script>

<style scoped>
  h1{
    font-size: 32px;
    font-weight: bold;
    padding: 15px;
    color: mediumaquamarine;
  }
  .add_customer{
    font-size: 16px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 5px;
    background-image: url('../../assets/icons/添加联系人.png');
    background-repeat: no-repeat;
    background-position: 98% 50%;
    background-size: 30px 30px;
  }
  th{
    font-weight: normal;
    font-size: 20px;
    text-align: center;
  }
  td{
    font-weight: normal;
    font-size: 18px;
    background: white;
    border-bottom: #cccc 2px solid;
    text-align: center;
  }
  .btn{
    color: #66cdaa;
  }
</style>
